package com.zhenwei.zscm.controller;

import com.zhenwei.zscm.common.annotations.MethodName;
import com.zhenwei.zscm.common.base.RestResult;
import com.zhenwei.zscm.model.vo.orderProductCheck.OneKeyPriceVO;
import com.zhenwei.zscm.model.vo.orderProductCheck.OrderProductCheckVO;
import com.zhenwei.zscm.service.OrderProductCheckService;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("/api/order/product/check")
@MethodName("工单产品检测管理")
public class OrderProductCheckController {
    private OrderProductCheckService orderProductCheckService;

    @MethodName("添加工单产品检测数据")
    @PostMapping("/create")
    public RestResult create(@RequestBody @Valid OrderProductCheckVO vo) {
        return orderProductCheckService.create(vo);
    }

    @MethodName("修改工单产品检测数据")
    @PostMapping("/update")
    public RestResult update(@RequestBody @Valid OrderProductCheckVO vo) {
        return orderProductCheckService.update(vo);
    }

    @MethodName("获取工单产品检测数据明细")
    @GetMapping("/detail")
    public RestResult detail(@RequestParam @NotEmpty(message = "工单ID不能为空") String orderId,@RequestParam @NotEmpty(message = "产品SN不能为空") String productSn) {
        return orderProductCheckService.detail(orderId,productSn);
    }

    @MethodName("一键工单产品报价")
    @PostMapping("/price")
    public RestResult oneKeyPrice(@RequestBody @Validated OneKeyPriceVO vo) {
        return orderProductCheckService.oneKeyPrice(vo);
    }
}

